<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <%--多附件上传css--%>
    <link rel="stylesheet" href="<s:url value="/assets/css/main.css"></s:url>"/>
    <style>
        /* 记录 */
        .record{
            padding-bottom: 10px;
        }
        .record_caption {
            width: 500px;
            height: 60px;
            margin: 15px auto;
            display: flex;
            flex-flow: row nowrap;
        }
        .record_hr {
            width: 130px;
            height: 4px;
            background-color: #333;
            margin-top: 28px;
        }
        .caption_text {
            width: 240px;
            height: 60px;
            line-height: 60px;
            font-size: 25px;
            text-align: center;
            color: #333;
            font-weight: 500;
        }
        .allrecord{
            width: 100%;
        }
        .record {
            width: 100%;
            background-color: rgba(0, 0, 0, 0.03);
            margin-top: 20px;
        }
        .record_title {
            height: 40px;
            line-height: 40px;
            display: flex;
            flex-flow: row nowrap;
            text-align: left;
            background-color: rgba(0, 0, 0, 0.1);
            padding: 0 20px;
            margin-bottom: 20px;
        }
        .record_div {
            height: 40px;
            line-height: 20px;
            display: flex;
            flex-flow: row nowrap;
            text-align: left;
            padding: 0 20px;
        }
        .record_div2 {
            line-height: 20px;
            display: flex;
            flex-flow: row nowrap;
            text-align: left;
            padding: 0 20px;
        }
        .record_text1 {
            width: 110px;
        }
        .record_text2 {
            flex: 1;
        }
        .record_text3 {
            flex: 1;
            line-height: 20px;
            white-space: normal;
            word-break: break-all;
            word-wrap: break-word;
        }
        .record_text3 .download_text{
            margin-bottom: 10px;
        }
        .record_text3 .download_botton {
            display: inline-block;
            width: 60px;
            height: 25px;
            line-height: 25px;
            text-align: center;
            color: white;
            background-color: #0e84ff;
            border-radius: 5px;
            margin-left: 20px;
            cursor: pointer;
        }
    </style>
</head>
<body class="no-skin">
<%--上传成功模态框--%>
<div class="shade" style="display: none;"></div>
<div class="warning" style="display: none;">
    <p class="title"><em></em><span class="close">X</span></p>
    <p class="cont"></p>
    <div class="la-square-jelly-box la-3x">
        <div></div>
        <div></div>
    </div>
</div>
<div class="modal fade" id="UrgeModel" tabindex="-1" role="dialog"  aria-hidden="true"
     data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">催办</h4> </div>
            <div class="modal-body ">
                <div class="information">
                    <div class="form-group clearfix">
                        <label class="control-label col-sm-2 text-right">姓名</label>
                        <div class="col-sm-9">
                            <input type="text" class="Modelname form-control" readonly >
                        </div>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label col-sm-2 text-right">电话</label>
                        <div class="col-sm-9">
                            <input type="text" class="Modelphone form-control" readonly >
                        </div>
                    </div>
                </div>
                <div class="form-group clearfix">
                    <div class="col-sm-offset-2 col-sm-6">
                        <input type="checkbox" value="1" name="type">推送主要领导
                    </div>
                </div>
                <div class="form-group clearfix">
                    <label class="control-label col-sm-2 text-right">常用语句</label>
                    <div class="col-sm-9">
                        <select class="form-control">
                            <option value="">点击选择</option>
                            <option>速度办理</option>
                            <option>及时办理</option>
                        </select>
                    </div>
                </div>
                <div class="form-group clearfix">
                    <label class="control-label col-sm-2 text-right">催办内容</label>
                    <div class="col-sm-9">
                        <textarea rows="3" class="form-control" style="resize: vertical;min-height: 100px"></textarea>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-success UrgeSure" data-dismiss="modal">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<div class="modal fade" id="approval" tabindex="-1" role="dialog" aria-hidden="true"
     data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">审批</h4> </div>
            <div class="modal-body ">
                <div class="information1">
                    <div class="form-group clearfix">
                        <label class="control-label col-sm-2 text-right">任务名称</label>
                        <div class="col-sm-9">
                            <input type="text" class="mainName form-control" readonly value="">
                        </div>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label col-sm-2 text-right">内容</label>
                        <div class="col-sm-9">
                            <textarea type="text" class="Modelcontent form-control" readonly ></textarea>
                        </div>
                    </div>
                    <div class="form-group clearfix">
                        <div class="col-sm-9 col-sm-offset-2">
                            <input type="radio" name="isApproval" value="2">通过
                            <input type="radio" name="isApproval" value="1">不通过
                        </div>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label col-sm-2 text-right">审批意见</label>
                        <div class="col-sm-9">
                            <textarea rows="3" class="form-control content"></textarea>
                        </div>
                        <input type="hidden" class="taskMain" taskMain="${taskMain.sysId}">
                        <input type="hidden" class="sysId" value="">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-success addApproval" data-dismiss="modal">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<%--修改--%>
<div class="modal fade" id="modify" tabindex="-1" role="dialog"  aria-hidden="true"
     data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">修改</h4> </div>
            <div class="modal-body " style="padding-left: 20px">
                <%--时限 类型--%>
<%--                <div class="form-group clearfix">--%>
<%--                    <label class="control-label col-sm-2 text-right">任务时限</label>--%>
<%--                    <div class="col-sm-9">--%>
<%--                        <input type="text" readonly lay-verify="date" placeholder="年-月-日" autocomplete="off" class="form-control date_picker" name="getTimeLimit" readonly>--%>
<%--                    </div>--%>
<%--                </div>--%>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right">周期类型<font color="red">*</font></label>
                            <div class="col-sm-3">
                                <select name="timeType" id="thexiugName" onchange="chanceTheSelect(this.options[this.options.selectedIndex].value)">
                                    <%--                <option value="">请选择</option>--%>
                                    <option value="多时限">多时限</option>
                                    <option value="单时限">单时限</option>
                                    <option value="天">天</option>
                                    <option value="周">周</option>
                                    <option value="月">月</option>
                                    <option value="季度">季度</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 20px">
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right">时限<font color="red">*</font></label>
                            <div class="col-sm-5" id="shijianxuanxiangaaa">
                                <input type="text" name="cell4"   value="${excelData.cell4}" class="form-control chance2_1_17" required >
                            </div>
                        </div>
                    </div>
                <input type="hidden" name="sysId">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-success confirmModify" data-dismiss="modal">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>


<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <%--多附件上传的name和id--%>

    <input type="text" name="file" value=""  hidden>
    <input type="text" name="fileName" value="" hidden>

    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <!-- /section:settings.box -->
                <h3 class="text-center">攻坚任务-任务清单</h3>
                <div id="taskMainId" style="display: none">
                    ${taskMainId}
                </div>
                <div id="gongjianId"  style="display: none">
                    ${gjId}
                </div>

                <div class="form-group clearfix">
                    <h3 class="text-left">
                        任务名称:${taskMain.mainName}
                    </h3>
                </div>
                <div class="form-group clearfix">
                    <c:if test="${not empty taskMain.content}">
                    <h4 class="text-left">
                        任务内容:${taskMain.content}
                    </h4>
                    </c:if>
                </div>
                <div class="form-group clearfix">
                    <c:if test="${ not empty taskMain.fileNumber}">
                        <div class="pull-left">
                            <h3 class="text-left">
                                文号:${taskMain.fileNumber}
                            </h3>
                        </div>
                    </c:if>
                    <c:if test="${ not empty taskMain.overdueDept}">
                        <div class="pull-left">
                            <h3 class="text-left overdueDept">
                                督办单位:${overdueDept.deptName}
                            </h3>
                        </div>
                    </c:if>
                </div>
                <div class="form-group clearfix">
                    <c:if test="${not empty taskMain.files}">
                    <h4 class="col-sm-1">
                        附件:
                    </h4>
                    <div class="col-sm-9">
                        <%--<input type="text" disabled value="${taskMain.fileName}"><button class="btn-success btn-sm" FileSysId="${taskMain.file}" onclick="download(this)" style="margin-left: 10px">下载附件</button>--%>
                            <c:if test="${not empty taskMain.files}">
                                <c:forEach items="${taskMain.files}" var="fileMap">
                                    <div style="margin-bottom:15px;">
                                        <input style="width: 50%;" type="text" class="fileName" readonly
                                               title="${fileMap.fileName}"
                                               value="${fileMap.fileName}" onclick="copyFile(this)">
                                        <button class="btn btn-primary file" onclick="download(this)"
                                                FileSysId="${fileMap.file}">
                                            下载附件
                                        </button>
                                    </div>
                                </c:forEach>
                            </c:if>
                            <c:if test="${empty taskMain.files}">
                                <input style="width: 50%;" type="text" value="无附件" class=" col-sm-3 form-control" readonly>
                            </c:if>
                    </div>
                    </c:if>
                </div>
                <div class="form-group clearfix">
                    <c:if test="${not empty taskMain.gJFile}">
                        <h4 class="col-sm-1">
                            攻坚附件:
                        </h4>
                        <div class="col-sm-9">
                            <%--<input type="text" disabled value="${taskMain.gJFileName}"><button class="btn-success btn-sm" FileSysId="${taskMain.gJFile}" onclick="download(this)" style="margin-left: 10px">下载附件</button>--%>
                                <c:if test="${not empty taskMain.gJFile}">
                                    <c:forEach items="${taskMain.gJFile}" var="fileMap">
                                        <div style="margin-bottom:15px;">
                                            <input style="width: 50%;" type="text" class="fileName" readonly
                                                   title="${fileMap.fileName}"
                                                   value="${fileMap.fileName}" onclick="copyFile(this)">
                                            <button class="btn btn-primary file" onclick="download(this)"
                                                    FileSysId="${fileMap.file}">
                                                下载附件
                                            </button>
                                        </div>
                                    </c:forEach>
                                </c:if>
                                <c:if test="${empty taskMain.gJFile}">
                                    <input style="width: 50%;" type="text" value="无附件" class=" col-sm-3 form-control" readonly>
                                </c:if>
                        </div>
                    </c:if>
                </div>
               <%-- <c:if test="${not empty taskMain.crucialUser}">
                    <c:choose>
                        &lt;%&ndash;读&ndash;%&gt;
                        <c:when test="${dept.sysId == '20190722100000000194'}">
                            <div class="form-group clearfix">
                                <div>
                                    <label class="col-sm-1 control-label">攻坚反馈:</label>
                                    <div class="col-sm-9">
                                        <textarea rows="1" class="form-control FeedbackContent"  placeholder="请输入内容" readonly style="resize: vertical;min-height: 50px;">${taskMain.mainResult}</textarea>
                                    </div>
                                </div>
                            </div>
                          &lt;%&ndash;  <div class="form-group clearfix">
                                <label class="control-label col-sm-1">反馈附件:</label>
                                <div class="col-sm-8">
                                    &lt;%&ndash;下载&ndash;%&gt;
                                        <input type="text" readonly value="${taskMain.mainResultFileName}">
                                        <button class="btn btn-primary" onclick="download(this)" FileSysId = "${taskMain.mainResultFile}">
                                            下载附件
                                        </button>
                                    &lt;%&ndash;上传&ndash;%&gt;
                                </div>
                            </div>&ndash;%&gt;
                            &lt;%&ndash;循环附件下载&ndash;%&gt;
                            <div class="form-group clearfix">
                                <label class="control-label col-sm-1">反馈附件:</label>
                                <div class="col-sm-8">
                                    <c:if test="${not empty taskMain.mainResultFile}">
                                        <c:forEach items="${taskMain.mainResultFile}" var="fileMap">
                                            <div style="margin-bottom:15px;">
                                                <input style="width: 50%;" type="text" class="fileName" readonly
                                                       title="${fileMap.fileName}"
                                                       value="${fileMap.fileName}" onclick="copyFile(this)">
                                                <button class="btn btn-primary file" onclick="download(this)"
                                                        FileSysId="${fileMap.file}">
                                                    下载附件
                                                </button>
                                            </div>
                                        </c:forEach>
                                    </c:if>
                                    <c:if test="${empty taskMain.mainResultFile}">
                                        <input style="width: 50%;" type="text" value="无附件" class=" col-sm-3 form-control" readonly>
                                    </c:if>
                                </div>
                            </div>
                            &lt;%&ndash;---以上为附件下载--&ndash;%&gt;
                        </c:when>
                        &lt;%&ndash;写&ndash;%&gt;
                        <c:otherwise>
                            <div class="form-group clearfix">
                                <div>
                                    <label class="col-sm-1 control-label">攻坚反馈:</label>
                                    <div class="col-sm-9">
                                        <textarea rows="1" class="form-control"  name="mainResult" placeholder="请输入内容" style="resize: vertical;min-height: 50px;">${taskMain.mainResult}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group clearfix">
                                <label class="control-label col-sm-1">反馈附件:</label>
                                <div class="col-sm-8">
                                    <c:if test="${not empty taskMain.mainResultFile}">
                                        <c:forEach items="${taskMain.mainResultFile}" var="fileMap">
                                            <div style="margin-bottom:15px;">
                                                <input style="width: 50%;" type="text" class="fileName" readonly
                                                       title="${fileMap.fileName}"
                                                       value="${fileMap.fileName}" onclick="copyFile(this)">
                                                <button class="btn btn-primary file" onclick="download(this)"
                                                        FileSysId="${fileMap.file}">
                                                    下载附件
                                                </button>
                                            </div>
                                        </c:forEach>
                                    </c:if>
                                    <c:if test="${empty taskMain.mainResultFile}">
                                        <input style="width: 50%;" type="text" value="无附件" class=" col-sm-3 form-control" readonly>
                                    </c:if>
                                    &lt;%&ndash;<c:if test="${not empty taskMain.mainResultFile}">
                                        &lt;%&ndash;下载&ndash;%&gt;
                                        <input type="text" readonly value="${taskMain.mainResultFileName}">
                                        <button class="btn btn-info" FileSysId = "${taskMain.mainResultFile}"  onclick="download(this)"><span class="glyphicon glyphicon-save"></span>下载附件</button>
                                    </c:if>&ndash;%&gt;
                                        &lt;%&ndash;上传&ndash;%&gt;
                                    <div>
                                        <div id="uploader"></div>
                                       &lt;%&ndash; <div style="display: inline-block">
                                            <input type="file" class="fileBorder" id="fileuploadGJX">
                                        </div>
                                        <div style="display: inline-block">
                                            <button class="btn btn-info" onclick="uploadFile(this,'mainResultFile','mainResultFileName','fileuploadGJX')">
                                                <span class="glyphicon glyphicon-open"></span>上传附件
                                            </button>
                                        </div>&ndash;%&gt;
                                    </div>
                                    <button class="btn btn-success takefeedback">确认</button>
                                </div>
                            </div>
                        </c:otherwise>
                    </c:choose>
                </c:if>
                <c:if test="${taskMain.categoryId == '20190919100000000001'}">
                    <c:choose>
                        &lt;%&ndash;读&ndash;%&gt;
                        <c:when test="${dept.deptRelation == '/01/'}">
                            <div class="form-group clearfix">
                                <div>
                                    <label class="col-sm-1 control-label">督办单位反馈:</label>
                                    <div class="col-sm-9">
                                        <textarea rows="1" class="form-control FeedbackContent"  placeholder="来自督办单位的反馈内容" readonly style="resize: vertical;min-height: 50px;">${taskMain.mainResult}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group clearfix">
                                <label class="control-label col-sm-1">反馈附件:</label>
                                <div class="col-sm-8">
                                    &lt;%&ndash;    &lt;%&ndash;下载&ndash;%&gt;
                                    <input type="text" readonly value="${taskMain.mainResultFileName}">
                                    <button class="btn btn-info" onclick="download(this)" FileSysId = "${taskMain.mainResultFile}">
                                        下载附件
                                    </button>&ndash;%&gt;
                                        <c:if test="${not empty taskMain.mainResultFile}">
                                            <c:forEach items="${taskMain.mainResultFile}" var="fileMap">
                                                <div style="margin-bottom:15px;">
                                                    <input style="width: 50%;" type="text" class="fileName" readonly
                                                           title="${fileMap.fileName}"
                                                           value="${fileMap.fileName}" onclick="copyFile(this)">
                                                    <button class="btn btn-primary file" onclick="download(this)"
                                                            FileSysId="${fileMap.file}">
                                                        下载附件
                                                    </button>
                                                </div>
                                            </c:forEach>
                                        </c:if>
                                        <c:if test="${empty taskMain.mainResultFile}">
                                            <input style="width: 50%;" type="text" value="无附件" class=" col-sm-3 form-control" readonly>
                                        </c:if>
                                </div>
                            </div>
                            <c:if test="${taskMain.status != '4'}">
                                <div class="form-group clearfix">
                                    <label class="control-label col-sm-1">是否办结:</label>
                                    <div class="col-sm-8">
                                        <button onclick="taskTtatus(4)" class="btn-sm btn btn-success">办结</button>
                                        <button onclick="taskTtatus(5)" class="btn btn-sm btn-danger">退回重办</button>
                                    </div>
                                </div>
                            </c:if>
                            <c:if test="${taskMain.status == '4'}">
                                <div class="form-group clearfix">
                                    <label class="control-label col-sm-1">评价:</label>
                                    <div class="col-sm-2 yc">
                                        <select class="form-control hg"  id ="task-evaluations">
                                            <option value="1">好</option>
                                            <option value="2">中</option>
                                            <option value="2">差</option>
                                        </select>
                                    </div>
                                    <button onclick="evaluations()" class="btn-sm btn btn-success">确认评价</button>
                                </div>
                            </c:if>
                        </c:when>
                        &lt;%&ndash;写&ndash;%&gt;
                        <c:when test="${dept.sysId == taskMain.overdueDept and roleId == '02'}">
                            <div class="form-group clearfix">
                                <div>
                                    <label class="col-sm-1 control-label">单位重大反馈:</label>
                                    <div class="col-sm-9">
                                        <textarea rows="1" class="form-control"  name="mainResult" placeholder="请输入内容" style="resize: vertical;min-height: 50px;">${taskMain.mainResult}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group clearfix">
                                <label class="control-label col-sm-1">单位反馈附件:</label>
                                <div class="col-sm-8">
                                    <c:if test="${not empty taskMain.mainResultFile}">
                                        <c:forEach items="${taskMain.mainResultFile}" var="fileMap">
                                            <div style="margin-bottom:15px;">
                                                <input style="width: 50%;" type="text" class="fileName" readonly
                                                       title="${fileMap.fileName}"
                                                       value="${fileMap.fileName}" onclick="copyFile(this)">
                                                <button class="btn btn-primary file" onclick="download(this)"
                                                        FileSysId="${fileMap.file}">
                                                    下载附件
                                                </button>
                                            </div>
                                        </c:forEach>
                                    </c:if>
                                    <c:if test="${empty taskMain.mainResultFile}">
                                        <input style="width: 50%;" type="text" value="无附件" class=" col-sm-3 form-control" readonly>
                                    </c:if>
                                    &lt;%&ndash;上传&ndash;%&gt;
                                    <div>
                                        <div id="uploader"></div>
                                        &lt;%&ndash;<div style="display: inline-block">&ndash;%&gt;
                                            &lt;%&ndash;<input type="file" class="fileBorder" id="fileuploadZDX">&ndash;%&gt;
                                        &lt;%&ndash;</div>&ndash;%&gt;
                                        &lt;%&ndash;<div style="display: inline-block">&ndash;%&gt;
                                            &lt;%&ndash;<button class="btn btn-info" onclick="uploadFile(this,'mainResultFile','mainResultFileName','fileuploadZDX')">&ndash;%&gt;
                                                &lt;%&ndash;<span class="glyphicon glyphicon-open"></span>上传附件&ndash;%&gt;
                                            &lt;%&ndash;</button>&ndash;%&gt;
                                        &lt;%&ndash;</div>&ndash;%&gt;
                                    </div>
                                    <button class="btn btn-success takefeedbackWd">确认</button>
                                    <button class="btn btn-info " onclick="duchaRank()" >排名</button>
                                </div>
                            </div>
                        </c:when>
                    </c:choose>
                </c:if>--%>
                <div class="pull-right" style="margin-bottom: 20px;margin-top: 20px;margin-bottom: 10px;">
                    <%--<button class="btn-sm btn btn-success allTasks">全部任务</button>--%>
                    <c:if test="${taskMain.status == 0}">
                        <button class="btn-success btn btn-sm approval">审批</button>
                    </c:if>
                    <%--<button class="btn-sm btn btn-success addTaskSub">新增子事项</button>
                    <button class="btn-sm btn btn-success addTaskUnitBtn">新增单位</button>--%>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <!-- jqGrid表格 -->
                        <table id="gridTable"></table>
                        <!-- jqGrid工具类 -->
                        <div id="gridPager"></div>
                        <!-- 查询对话框 -->
                        <div style="display: none;">
                            <div class="row" id="queryDialog"></div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
                <h4 class="redTips">温馨提示：双击表格行或者点击"查看" 查看任务详情</h4>
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

    <%@ include file="/WEB-INF/views/include/dialog.jsp" %>
</div><!-- /.main-container -->
</div>

<%--多选上传--%>
<script src="<s:url value="/assets/js/dist/easyUploader.jq.js"></s:url>"></script>
<!-- footer -->
<%@ include file="/WEB-INF/views/include/footer.jsp" %>
<%--用于没上传附件时不执行方法--%>
<input type="text" id="crucialUser" value="${taskMain.crucialUser}" hidden>
<input type="text" id="overdueDept" value="${taskMain.overdueDept}" hidden>

<input type="text" id="sysIds" value="${dept.sysId}" hidden>
<input type="text" id="categoryId" value="${taskMain.categoryId}" hidden>

<input type="text" id="deptRelations" value="${dept.deptRelation}" hidden>
<input type="text" id="roleIds" value="${roleId}" hidden>

<input type="text" id="gjId" value="${gjId}" hidden>
<input type="text" id="timeRound" value="${timeRound}" hidden>


<div class="record_caption">
    <div class="record_hr"></div>
    <div class="caption_text">本轮督办反馈记录</div>
    <div class="record_hr"></div>
</div>
<div class="allrecord"></div>

<%--督办单位反馈记录--%>
<script>
    function orderSort(attr) {
        return function (obj1, obj2) {
            var value1 = obj1[attr];
            var value2 = obj2[attr];
            if (!isNaN(Number(value1)) && !isNaN(Number(value2))) {
                var val1 = Number(value1);
                var val2 = Number(value2);
                value1 = val1;
                value2 = val2;
            }
            if (value1 > value2) {
                return -1;
            } else if (value1 < value2) {
                return 1;
            } else {
                return 0;
            }
        };
    }
    // 参数先写死
    var param_timeRound = document.getElementById("timeRound").value
    var param_gjid = document.getElementById("gjId").value
    //请求攻坚反馈信息接口
    var gjid;
    var timeRound
    $.ajax({
        url:'/taskMain/historyDuBan?gjId='+param_gjid+'&timeRound='+param_timeRound+'&deptType=4',
        dataType:'json',
        type:'get',
        contentType:'application/json',
        success:function (res) {
            console.log("999999999999")
            console.log(res)
            var html="";
            var dataArr = []
            for (let i = 0; i < res.data.length; i++) {
                dataArr.push({
                    time:res.data[i].createDate + " " + res.data[i].createTime,
                    content:res.data[i].content,
                    problem:res.data[i].problem,
                    plan:res.data[i].plan,
                    fileDto:res.data[i].fileDto,
                    userName:res.data[i].userName,
                })
            }
            var newdata =  dataArr.sort(orderSort("time"))
            var html = ""
            for (let i = 0; i < newdata.length; i++) {
                let file_div = ""
                if(newdata[i].fileDto == ""||newdata[i].fileDto==undefined||newdata[i].fileDto==null){
                    file_div = '<div class="download_text"> 无</div>'
                }else{
                    for (let j = 0; j < newdata[i].fileDto.length; j++) {
                        file_div += '<div class="download_text"> ' +
                            '<input type="hidden" class="xiazaiwenjianid" value="'+ newdata[i].fileDto[j].fileId +'"> ' +
                            '<a href="javascript:;"  style="display: inline-block;width: 150px;"  class="xiazaiwenjianming">'+newdata[i].fileDto[j].fileName+'</a>' +
                            '<div class="download_botton xiazaiwenjiananniu">下载</div>' +
                            '</div>'
                    }
                }
                html +=  '<div class="record">'+
                    '<div class="record_title">'+
                    '<div class="record_text1">反馈时间：</div>'+
                    '<div class="record_text2">'+(newdata[i].time?newdata[i].time:"")+'</div>'+

                    '<div class="record_text1">反馈人：</div>'+
                    '<div class="record_text2">'+(newdata[i].userName?newdata[i].userName:"")+'</div>'+


                    '</div>'+
                    '<div class="record_div">'+
                    '<div class="record_text1">办理情况：</div>'+
                    '<div class="record_text3">'+(newdata[i].content?newdata[i].content:"")+'</div>'+
                    '</div>'+
                    '<div class="record_div">'+
                    '<div class="record_text1">存在问题：</div>'+
                    '<div class="record_text3">'+(newdata[i].problem?newdata[i].problem:"")+'</div>'+
                    '</div>'+
                    '<div class="record_div">'+
                    '<div class="record_text1">下步计划：</div>'+
                    '<div class="record_text3">'+(newdata[i].plan?newdata[i].plan:"")+'</div>'+
                    '</div>'+
                    '<div class="record_div2">'+
                    '<div class="record_text1">附件下载：</div>'+
                    '<div class="record_text3">'+
                    file_div +
                    '</div>'+
                    '</div>'+
                    '</div>'
            }
            var allrecord = document.querySelector(".allrecord")
            allrecord.innerHTML = html
            var xiazaiwenjianid = document.querySelectorAll(".xiazaiwenjianid")
            var xiazaiwenjianming = document.querySelectorAll(".xiazaiwenjianming")
            var xiazaiwenjiananniu = document.querySelectorAll(".xiazaiwenjiananniu")
            for (let i = 0; i < xiazaiwenjiananniu.length; i++) {
                xiazaiwenjiananniu[i].onclick = function(){
                    window.open('/filesUpload/download?id='+xiazaiwenjianid[i].value+'&name='+xiazaiwenjianming[i].innerText)
                }
            }

        }
    });
</script>



<script type="text/javascript">
    // 基本路径
    var baseUrl = "<s:url value="/taskMain/gjmaintask/"></s:url>"

    // jqgrid的表格高度
    var height = 320;
    // jqgrid表格行头的中文
    /*var colNames = ['','任务名称','督查组',"时限","轮次", "任务状态","逾期天数",/!*"操作"*!/];

    var colModel = [
        {name: 'sysId', width: 60, hidden: true, key: true},
        {name: 'mainName',index :'mainName', width: 150, },
        {name: 'deptName', index: 'deptName', width: 150, editable: true },
        {name: 'timeLimit', index: 'timeLimit', width: 100, editable: true, },
      //  {name: 'timeRound', index: 'timeRound', width: 100, editable: true,formatter:timeRoundFormatter},
        {name: 'type', index: 'type', width: 100, editable: true,formatter:typeFormatter},
        {name: 'overdueDay', index: 'overdueDay', width: 150, editable:true,formatter:overdueDayFormatter},
       // {name : 'cz', width : 250, align : "center", formatter:feedbackBtnFormatter}
    ];*/

    var colNames = ['', '任务名称', "任务内容","督查组单位","附件","状态","操作"];
    var colModel = [
        {name: 'sysId', width: 60, hidden: true, key: true},
        {name: 'mainName', index: 'mainName', width: 250, editable: true},
        {name: 'content', index: 'content', width: 250, editable: true},
        // {name: 'categoryId', index: 'categoryId', width: 250, editable: true, formatter: categoryIdFormatter},
        {name: 'deptName', index: 'deptName', width: 250, editable: true},
        {name: 'file', index: 'file', width: 250, editable: true,formatter:fileFormatter},
        {name: 'status', width: 150, editable: true,formatter:statusFormatter},
        {name : 'sy', width : 150, align : "center",formatter:urgentFormatter}
    ];


    // jqgrid的具体执行方法
    var rowIds;
    var userList;
    var type;
    var taskSubId;
    jqgrid({
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager",
        postData:{'gjId':$('#gongjianId').html().trim()},
        autoScroll: false,
        shrinkToFit: true,
        multiselect:false,
        rownumbers: true,
        onSelectRow: function (rowid, status) {
            rowIds = rowid
            //选择当前的行
            rowids = rowid
            var selectedRowValue = $("#gridTable").jqGrid('getRowData', rowid);
            var types = selectedRowValue.type;//获取任务状态
            //
           // taskSubId=selectedRowValue.taskSubId;
          //  console.log(taskSubId);
        },
        ondblClickRow:function (rowid) {
            console.log("dianji"+rowid)
            window.parent.openapp("/taskMain/query2/"+rowid,'gjtasks',"任务详情");

        },
        loadComplete:function (data) {
            var ids = $("#gridTable").jqGrid("getDataIDs");
            var rowDatas = $("#gridTable").jqGrid("getRowData");//获取所有行的数据
            for (var i = 0; i<rowDatas.length;i++){
                if (data.rows[i].type == 2){
                    $("#"+ids[i]+ " td").css("background","yellow"); //已反馈
                };
                if (data.rows[i].overdueDay){
                    $("#"+ids[i]+ " td").css("color","red"); //逾期
                }
            }
        },
    });

    function statusFormatter(value, grid, rows, state) {
        console.log(grid, rows, state);
        grid.colModel.title=false
        if(rows.status=='9') {
            return '待立项'
        }else if (rows.status=='2'){
            return '正常'
        }else {
            return "未知"
        }
    }

    function urgentFormatter(value, grid, rows, state) {
        console.log(grid, rows, state);
        grid.colModel.title=false
        var html = "<div style='color: #049CE6;display: flex;justify-content: center'>"
        if(rows.createUser !=undefined && rows.crucialUser != undefined) {

                html += "<div style='width: 40px;cursor: pointer' title='查看'>查看</div>"

        }
        html += "</div>"
        return  html;

    }
    /**
     * 按钮`
     */
    function feedbackBtnFormatter   (value, grid, rows, state) {
        grid.colModel.title=false
        return "<div style='color: #049CE6;display: flex;justify-content: center'>" +
            "<div style='width: 60px;cursor: pointer;border-right:1px solid #049CE6;' title='反馈汇总' id='feedbackBtn1'>反馈汇总</div>" +
            "<div style='width: 40px;cursor: pointer' title='查看' id='feedbackBtn'>查看</div>" +
            "<div style='border-left:1px solid #049CE6;width: 40px;cursor: pointer'title='删除' class='delTask'>删除</div>" +
            "<div style='width: 40px;cursor: pointer;border-left:1px solid #049CE6;' class='urge' title='催办'>催办</div>" +
            "<div style='width: 40px;cursor: pointer;border-left:1px solid #049CE6;' class='modify' title='修改'>修改</div>" +
            "</div>";
    }

    /**
     * 任务时限轮数
     */
      function timeRoundFormatter(data) {
        return "第"+ data + "轮"
    }

    /**
     * 任务类型格式化
     */
    function categoryIdFormatter(data) {
      switch (data){
          case '1':
              return '牵头';
              break;
          case '2':
              return '协办';
              break;
          default:
              return '未知';
      }
    }


    /**
     * 任务状态格式化
     */
    function typeFormatter(data) {
        switch(data) {
            case '0':
                return '待签收';
                break;
            case '1':
                return '待反馈';
                break;
            case '2':
                return '已反馈';
                break;
            case '3':
                return '退回重办';
                break;
            case '4':
                return '完成';
                break;
            case '5':
                return '已签收';
                break;
            default:
                return '未知';
        }
    }

    /**
     * 逾期天数
     */
    function overdueDayFormatter(data) {
        data = parseInt(data)
        if(data>0){
            return parseInt(data)+"天"
        }else {
            return ""
        }
    }
    /**
     * 附件格式化
     */
    function fileFormatter(data) {
        if (data == null || data == "") {
            return "无任务附件";
        } else {
            return '<input type="button" value="下载" onclick="downDetail(\'' + data + '\')" \n' +
                ' style="width: 100%; height: 32px;" class="btn-large btn-primary"/>';
        }
    }




    //点击开二级页面
$(document).on("click","#feedbackBtn1",function(){
        parent.openapp("/taskMain/collect/"+rowIds,rowIds,"反馈汇总");
    });
    $(document).on("click","#feedbackBtn",function(){
        parent.openapp("/taskMain/unitDetail/"+rowIds,rowIds,"任务详情");
    });

    //    催办
    $(document).on("click",".urge",function () {
        $.get("/taskMain/urgeModel/"+rowIds,function (data) {
            userList = data;
            var html = "";
            for (var i = 0; i < data.length;i++){
                if (data[i].name == undefined) {
                    data[i]['name'] = ''
                }
                if(data[i].mobile == undefined) {
                    data[i]['mobile'] = ''
                }
                html += " <div class=\"form-group clearfix\">\n" +
                    "                        <label class=\"control-label col-sm-2 text-right\">姓名</label>\n" +
                    "                        <div class=\"col-sm-9\">\n" +
                    "                            <input type=\"text\" class=\"Modelname form-control\" readonly value='"+data[i].name+"'>\n" +
                    "                        </div>\n" +
                    "                    </div>\n" +
                    "                    <div class=\"form-group clearfix\">\n" +
                    "                        <label class=\"control-label col-sm-2 text-right\">电话</label>\n" +
                    "                        <div class=\"col-sm-9\">\n" +
                    "                            <input type=\"text\" class=\"Modelphone form-control\" readonly value='"+data[i].mobile+"'>\n" +
                    "                        </div>\n" +
                    "                    </div>"
            }

            $(".information").html(html);
        });
        $('#UrgeModel').modal('show'); //显示
    });

    $("#UrgeModel select").change(function () {
        $("#UrgeModel textarea").val( $(this).val());
    })

    $(".UrgeSure").click(function () {
        failure(".UrgeSure",1)
        type = $("input[name='type']:checked").val();
        if (!type){
            type = 0;
        }
        var datas = {
            taskUnitId: rowIds,
            content: $("#UrgeModel textarea").val(),
            userList:userList,
            type:type
        }
        var jsonDatas = JSON.stringify(datas);
        $.ajax({
            url:'/taskMain/saveHasten/',
            type:'POST',
            contentType: 'application/json; charset=UTF-8',
            async:false,
            dataType:'json',
            data:jsonDatas,
            success: function (data) {
                if (data.code == "200") {
                    alert("催办成功");
                    $("#UrgeModel textarea").val("");
                    $("input[name='type']").removeAttr("checked");
                } else {
                    alert("催办失败");
                }
                failure(".UrgeSure",0)
            }
        })
    })






    //审批
    $(document).on("click",".approval",function () {
        var  sysId = $(".taskMain").attr("taskMain")
        $('#approval').modal('show'); //显示
        $.get("/taskMain/approve/"+sysId,function (data) {
            $(".Modelcontent").val(data.content);
            $(".mainName").val(data.mainName);
            $(".sysId").val(data.sysId);

        })
    });
    $(".addApproval").click(function () {
        var datas = {
            status:$("[name='isApproval']:checked").val(),
            content:$(".information1 .content").val(),
            taskMainId:$(".sysId").val()
        }
        if (!datas.status){
            return alert("请选择是否通过 ")
        }
        $.post("/taskMain/approve/",datas,function (data) {
            if (data.code==200) {
                datas.status == 2 ? alert("通过审批") : alert("不通过审批")
                open(location, '_self').close();
            }else {
                alert("审批失败");
            }
        })
    })
    
    //攻坚反馈 takefeedback
    $(".takefeedback").click(function() {
        failure("takefeedback",0)
        var datas ={
                mainResult:$("textarea[name='mainResult']").val() ,
                mainResultFile:$("input[name=file]").val(),
                sysId:$(".taskMain").attr("taskMain"),
                mainResultFileName:$("input[name=fileName]").val()
            };
            $.ajax({
                url:"/taskMain/saveMainResult",
                type:"post",
                data:datas,
                success:function (data) {
                    if(data.code == "200"){
                        alert(data.message);
                        setTimeout(function () {
                            open(location, '_self').close();
                        },50)
                    }else if(data.code == "500"){
                        alert(data.message);
                    }
                    failure("takefeedback",1)
                }
            })
        })


    //单位反馈
    $(".takefeedbackWd").click(function() {
        failure(".takefeedbackWd",1)
        var datas ={
            mainResult:$("textarea[name='mainResult']").val() ,
            mainResultFile:$("input[name=file]").val(),
            sysId:$(".taskMain").attr("taskMain"),
            mainResultFileName:$("input[name=fileName]").val()
        }
       /* var datas ={
            content:$("textarea[name='mainResult']").val() ,
            file:$("input[name=file]").val(),
            taskMainId:$(".taskMain").attr("taskMain"),
            fileName:$("input[name=fileName]").val()
        }*/
        $.ajax({
           // url:"/taskUnit/saveMainResult",
            url:"/taskUnit/saveDuBanBackInfo",
            type:"post",
            data:datas,
            success:function (data) {
                if(data.code == "200"){
                    alert(data.message);
                    setTimeout(function () {
                        open(location, '_self').close();
                    },50)
                }else if(data.code == "500"){
                    alert(data.message);
                }
                failure(".takefeedbackWd",0)
            }
        })
    })

    //是否办结
    function taskTtatus(status) {
        var datas = {
            sysId:$(".taskMain").attr("taskMain"),
            status:status
        }
        $.ajax({
            url:"/taskMain/updateMainStatus/",
            type:"post",
            data:datas,
            success:function (data) {
               alert(data.message);
               setTimeout(function () {
                   open(location, '_self').close();
               },50)
            }
        })
    }

    /*修改任务*/
    $(document).on("click",".date_picker",function () {
        laydate({
            elem: this,
            min: minDate(),
        });
    });
    $(document).on("click",".modify",function () {
        $.get("/taskMain/getTaskUnit/"+rowIds,function (res) {
            $("input[name=thegetTimeLimit]").val(res.data.timeLimit)
            $("input[name=sysId]").val(res.data.sysId)
        })
        $("#modify").modal("show")
    })

    /*修改确认*/
    $(".confirmModify").click(function () {
            var datas = {
                subTimeLimit:$("input[name='thegetTimeLimit']").val()==undefined?$('#thegetTimeLimitid option:selected').val():$("input[name='thegetTimeLimit']").val(), //时限
                sysId:$("input[name='sysId']").val(),
                timeType:$('#thexiugName option:selected').val()
            }
            console.log(datas)
            $.post("/taskMain/editTaskUnit/",datas,function (data) {
                    if (data.code == 200){
                        alert("修改成功")
                        reload("#gridTable");//重载
                    }else {
                        alert("修改失败");
                    }
            })
    })

    //删除子事项
    $(document).on("click",".delTask",function () {
        if (confirm("是否删除")) {
            console.log("删除："+taskSubId);
            $.get("/taskMain/deleteUnit/" + taskSubId, function (res) {
                if (res.code == "200") {
                    alert(res.message);
                    setTimeout(function () {
                        open(location, '_self').close();
                    }, 50)
                } else {
                    alert(res.message);
                }
            })
        }
    })
   /* //新增子事项
    $(".addTaskSub").click(function () {
        var $taskMainSysId = $(".taskMain").attr("taskMain");
        loadDialog({
            dialogTitle: '新增子事项',
            dialogUrl: "/taskMain/addTaskSub/"+$taskMainSysId,
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">添加</button>' +
            '<button type="button" class="btn btn-default" onclick="removeLayDate()" data-dismiss="modal">关闭</button>'
        });
    })*/

    //新增子事项
   /* function create() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: "/taskMain/addTaskSub/",
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            failMessage: '保存失败',
            failTitle: '消息对话框'
        });
    }*/

    /*//新增子事项单位
    $(".addTaskUnitBtn").click(function () {
        var $taskMainSysId = $(".taskMain").attr("taskMain");
        loadDialog({
            dialogTitle: '新增单位',
            dialogUrl: "/taskMain/addTaskUnit/"+$taskMainSysId,
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="createTask()">添加</button>' +
            '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    })*/

 /*   //新增子事项单位
    function createTask() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: "/taskMain/addTaskUnit/",
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            failMessage: '保存失败',
            failTitle: '消息对话框'
        });
    }*/
    function minDate() {
        var now = new Date();
        return now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + (now.getDate() + 1);
    }
    $(document).ready(function (){
        $(document).on("click","#date_picker",function () {
            laydate({
                elem: "#date_picker",
                min: minDate(),
            });
        });
    })

    //bug 删除时间模态框
    function removeLayDate(){
        $("#laydate_box").remove()
    }


    //任务评价
    function evaluations() {

        var eval  = $("#task-evaluations").val();
        console.log(eval)

        var datas = {
            evaluations:eval, //评价
            sysId:$(".taskMain").attr("taskMain")
        }
        console.log(datas)
        $.post("/taskMain/submitEval",datas,function (data) {
            if (data.code == 200){
                alert("评价成功")
                reload("#gridTable");//重载
            }else {
                alert("修改失败");
            }
        })

    }

    function duchaRank() {
            var eval =$("#task-evaluations").val();//评价
           var  sysId=$(".taskMain").attr("taskMain");
        parent.openapp("/taskMain/dubanfeedback?sysId="+sysId+"&eval="+eval,"接收单位")
    }

</script>

<script>
    function chanceTheSelect(data){
        var xuanxianghtmlaaa = ""
        if(data == "多时限"){
            xuanxianghtmlaaa = "<div class='form-group'>" +
                "    <div class=\"col-sm-8 no-padding-left\">\n" +
                "        <input type=\"text\" placeholder=\"年-月-日\"  onblur=\"addTimeBtnDataaaa()\"     class=\"form-control  Zdate_picker date_picker danyanaaa\"   readonly>\n" +
                "    </div>\n" +
                "    <div class=\"col-sm-1 addTime\">\n" +
                "        <input type=\"button\" class=\"btn btn-sm btn-success\" onclick='addTimeBtn(this)' value=\"添加时限\">\n" +
                "        <input id=\"theshubmit\" type=\"hidden\" name=\"thegetTimeLimit\" class=\"form-control\" >\n" +
                "    </div>\n" +
                "    </div>"
        }
        if(data == "单时限"){
            xuanxianghtmlaaa = "<div class='form-group'>" +
                "    <div class=\"col-sm-8 no-padding-left\">\n" +
                "        <input type=\"text\" class=\"form-control Zdate_picker  date_picker transform\"  name=\"thegetTimeLimit\" readonly>\n" +
                "    </div>\n" +
                "    </div>"
        }
        if(data == "天"){
            xuanxianghtmlaaa = "<input type=\"number\" class=\"form-control\" min='0' name=\"thegetTimeLimit\"  placeholder=\"请输入天数\">"
        }
        if(data == "周"){
            xuanxianghtmlaaa  = "      <select name=\"thegetTimeLimit\" id=\"thegetTimeLimitid\" class=\"form-control\" value=\"\" >\n" +
                "            <option value=\"1\">星期一</option>\n" +
                "            <option value=\"2\">星期二</option>\n" +
                "            <option value=\"3\">星期三</option>\n" +
                "            <option value=\"4\">星期四</option>\n" +
                "            <option value=\"5\">星期五</option>\n" +
                "            <option value=\"6\">星期六</option>\n" +
                "            <option value=\"7\">星期日</option>\n" +
                "        </select>"
        }
        if(data == "月"){
            xuanxianghtmlaaa  = "<input type=\"text\" id=\"DBdate_pickeraaa\" value=\"\" readonly lay-verify=\"date\" name=\"thegetTimeLimit\" placeholder=\"日\" autocomplete=\"off\" class=\"layui-input form-control\">\n"
        }
        if(data == "季度"){
            xuanxianghtmlaaa  = "<input type=\"text\" value = \"\"    readonly lay-verify=\"date\" placeholder=\"年-月-日\" name=\"thegetTimeLimit\" autocomplete=\"off\" class=\"layui-input form-control date_picker\">\n"
        }
        $("#shijianxuanxiangaaa").html(xuanxianghtmlaaa)
    }
    function addTimeBtn(e) {
        var html = " <div class=\"form-group\" style=\"margin-top: 10px\">" +
            "   <div class=\"col-sm-8 no-padding-left\">\n" +
            "       <input  type=\"text\" value=\"\" readonly lay-verify=\"date\" onblur=\"addTimeBtnDataaaa()\"    placeholder=\"年-月-日\" autocomplete=\"off\" class=\"layui-input form-control date_picker danyanaaa\">\n" +
            "</div>\n" +
            "    <div class=\"col-sm-1 addTime\">\n" +
            "        <input type=\"button\" class=\"btn btn-sm btn-danger removeTimeBtn\"  value=\"删除时限\">\n" +
            "    </div>"+
        "</div>"
        $(e).parent().parent().parent().append(html);
    }

    function addTimeBtnDataaaa(){
        setTimeout(function(){
            var value = [];
            $(".danyanaaa").each(function() {
                value.push($(this).val());
            });
            $('#theshubmit').attr('value',value.join(","))
        },200)
    }
    chanceTheSelect("多时限")
    $(document).on("click","#DBdate_pickeraaa",function () {
        laydate({
            elem: "#DBdate_pickeraaa",
            format: 'YYYY-MM-DD',
            // min: minDate(),
            choose: function(data){
                //将值赋值给input框
                var $checked = $("input[name='period2']:checked").val();
                data = data.substring(data.length-2)
                $("#DBdate_pickeraaa").val(data);
            }
        });
    });

    $(document).on("click",".removeTimeBtn",function () {
        $(this).parent().parent().remove();
    });
</script>
</body>
</html>